<!DOCTYPE html>
<html>
    <head>
    <title>Document</title>
    <style>
        #e {
            width: 100px;
            height: 100px;
            background: red;
            position: absolute;
            left: 0;
            top: 0;
            zoom: 1;
        }
    </style>
    </head>
    <body>
        <div id="e"></div>
        <script>
            let e = document.getElementById('e');
            let flag = true;
            let left = 0;

            function render(){
                if(flag === true){
                    if(left >= 100){
                        flag = false;
                    }
                    e.style.left = `${left++}px`;
                }else{
                    if(left <= 0){
                        flag = true;
                    }
                    e.style.left = `${left--}px`;
                }
            }
            // requestAnimationFrame效果
            (function animationLoop(){
                render();
                window.requestAnimationFrame(animationLoop);
            })()
        </script>
    </body>
</html>